package com.example.administrator.myjdlc.activity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.myjdlc.R;
import com.example.administrator.myjdlc.base.BaseActivity;
import com.example.administrator.myjdlc.entity.Subject;
import com.example.administrator.myjdlc.httpservice.http.HttpMethods;
import com.example.administrator.myjdlc.httpservice.subscribers.ProgressSubscriber;
import com.example.administrator.myjdlc.httpservice.subscribers.SubscriberOnNextListener;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyMainActivity extends BaseActivity {

    @Bind(R.id.click_me_BN)
    Button clickMeBN;
    @Bind(R.id.result_TV)
    TextView resultTV;
    private SubscriberOnNextListener getTopMovieOnNext;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_activity_main);
        ButterKnife.bind(this);
        getTopMovieOnNext = new SubscriberOnNextListener<List<Subject>>() {
            @Override
            public void onNext(List<Subject> subjects) {
                resultTV.setText(subjects.toString());
            }
        };
    }

    @Override
    public void initBaseData() {

    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {

    }

    @OnClick(R.id.click_me_BN)
    public void onViewClicked() {
        getMovie();
    }
    //进行网络请求
    private void getMovie(){
        HttpMethods.getInstance().getTopMovie(new ProgressSubscriber(getTopMovieOnNext, MyMainActivity.this), 0, 10);

    }
}
